package server.business.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import server.business.pojo.BloodTest;
import server.business.service.BloodTestService;
import server.business.mapper.BloodTestMapper;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Galaxy
 * @description 针对表【blood_test】的数据库操作Service实现
 * @createDate 2022-11-08 12:46:24
 */
@Service("bloodTestService")
public class BloodTestServiceImpl extends ServiceImpl<BloodTestMapper, BloodTest>
        implements BloodTestService {


    //*************************************myq*************************start
    @Autowired
    private BloodTestMapper bloodTestMapper;

    @Override
    public List<BloodTest> getBloodInfo(String inspectionSheet) {
        return bloodTestMapper.showBlood(inspectionSheet);
    }

    @Override
    public ArrayList<Object> getTestInfo(String transfusionNumber) {
        return bloodTestMapper.showBloodTest(transfusionNumber);
    }
    //*************************************myq*************************end


    // *************************************lrz*************************start


    /**
     * 根据患者id在blood_test表中找到患者血型
     *
     * @param patientId
     * @return
     */
    @Override
    public String getBloodType(Long patientId) {
        LambdaQueryWrapper<BloodTest> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(BloodTest::getPatientId, patientId);
        BloodTest result = bloodTestMapper.selectOne(queryWrapper);
        if (result == null) {
            return null;
        }
        String bloodType = result.getBloodType();
        return bloodType;
    }

    /**
     * 根据患者id在blood_test表中找到患者RH血型
     *
     * @param patientId
     * @return
     */
    @Override
    public String getRhBloodType(Long patientId) {
        LambdaQueryWrapper<BloodTest> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(BloodTest::getPatientId, patientId);
        BloodTest result = bloodTestMapper.selectOne(queryWrapper);
        if (result == null) {
            return null;
        }
        String RhType = result.getRhd();
        return RhType;
    }

    //*************************************lrz*************************end



}




